home *** CD-ROM | disk | FTP | other *** search
- Path: sable.ox.ac.uk!worc0223
- From: worc0223@sable.ox.ac.uk (Benjamin Hutchings)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: x ^= y ^= x ^= y;
- Date: 22 Feb 1996 20:20:17 GMT
- Organization: Oxford University, England
- Message-ID: <4gij61$81i@news.ox.ac.uk>
- References: <1286.6624T1439T237@cs.ruu.nl>
- NNTP-Posting-Host: sable.ox.ac.uk
-
- In article <1286.6624T1439T237@cs.ruu.nl>,
- Wessel Dankers <wsldanke@cs.ruu.nl> wrote:
- [...]
- >Which can of course be rewritten as:
- >
- > x ^= y;
- > y ^= x;
- > x ^= y;
- >
- >or if you want it real fancy:
- >
- > x ^= y ^= x ^= y;
-
- Not guaranteed to work! Read the FAQ in one of the C newsgroups. This is a
- common lame mistake. The order of evaluation is not guaranteed and the
- compiler is entitled to optimise the assignments to execute in a variety of
- different ways. On some compilers this will work, on others not.
- --
- --
- Ben Hutchings, student. Finger me on worc0223@sable.ox.ac.uk for various info.
- email: benjamin.hutchings@worc.ox.ac.uk WWW: http://sable.ox.ac.uk/~worc0223/
- Users of the world unite! You have nothing to lose but your Micro$oft software
-